<?php $tabla = $_POST["tabla"];
$orden = $_POST["orden"];
$crite = $_POST["criterio"];
include_once("db_conect.php");
$qry = "select * from `".$tabla."`";
if (isset($crite)) $qry.=" Where ".$crite;
if (isset($orden)) $qry.=" Order by ".$orden;
$res = mysql_query($qry,$conexion) or die(mysql_error());
while ($row = mysql_fetch_assoc($res)) {
echo utf8_encode("<option value=\"".$row["id"]."\">".$row["descripcion"]."</option>");
}
mysql_free_result($res);
// cerrar conexion
mysql_close($conexion); ?>